# -*- coding: utf-8 -*-


lst=[]
for i in range(5):
    goods = input("请输入商品编号和名称进行入库，每次只能输入一次商品")
    lst.append(goods)
for item in lst:
    print(item)
cart=[]
while True:
    flag =False
    num = input("请输入要购买的商品编号:")
    for item in lst:
        if num  == item[0:4]:
            flag = True
            cart.append(item)
            print('商品已成功加入购物车')
            break
    if not flag and num!='q':
            print("商品不存在")
    if num =='q':
            break
    print("-"*50)
    print("您购物车已选择的商品为:")
    cart.reverse()
    for item in cart:
        print(item)

